<template>
	<view>
		<view class="top text-white">
			<view class="text">余额(元)</view>
			<view class="money">{{money}}</view>
			<view class="btns">
				<!-- <view class="btn">
					充值
				</view> -->
				<view class="btn" @click="$goto('/pages/mine/cash-out')">
					提现
				</view>
			</view>
			
			<view class="btm"></view>
		</view>
		
		<scroll-view scroll-x class="bg-white text-gray nav padding-lr" scroll-with-animation :scroll-left="scrollLeft">
			<view class="cu-item" :class="i.id==TabCur?'active cur':''" v-for="i in tab" :key="i.id" @tap="tabSelect" :data-id="i.id">
				{{i.text}}
			</view>
		</scroll-view>
		<view class="padding-bottom-xs" style="background-color: #EFEFEF;"></view>
		
		<view class="tab-list">
			<my-tab-item
				v-show="TabCur==0||TabCur==i.type"
				v-for="i in list"
				:key="i.id"
				img="../../static/images/w4.png" :title="i.reason" :info="i.info" :date="i.created_at" :change="i.amount"></my-tab-item>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				TabCur: 0,
				scrollLeft: 0,
				tab: [{
						id: 0,
						text: '全部'
					},
					{
						id: 2,
						text: '提现'
					},
					{
						id: 1,
						text: '收益'
					}
				],
				list: [],
				money: '0.00',
			}
		},
		onShow() {
			this.getData();
		},
		methods: {
			tabSelect(e) {
				this.TabCur = e.currentTarget.dataset.id;
				this.scrollLeft = (e.currentTarget.dataset.id - 1) * 60
			},
			getData() {
				this.$u.get('/finance/wallet').then(res => {
					let data = res.data.result
					this.money = data.balance
					this.list = data.logs
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	@keyframes move {
		to {
			background-position: 750px 0;
		}
	}

	.top {
		width: 100%;
		height: 500rpx;
		background: #1F1F1F;
		display: flex;
		flex-flow: column;
		align-items: center;
		justify-content: center;
		position: relative;
		color: #E4CB9B;
		
		.btm {
			width: 100%;
			height: 80rpx;
			position: absolute;
			bottom: 0;
			background-image: url(../../static/images/wbg.png);
			background-repeat-x: repeat;
			background-position: 0 0;
			animation: move 6s linear infinite;
		}

		.text {
			font-size: 30rpx;
		}

		.money {
			margin-top: 30rpx;
			font-size: 70rpx;
		}

		.btns {
			margin-top: 30rpx;
			display: flex;

			.btn {
				margin: 20rpx;
				width: 232rpx;
				height: 64rpx;
				border: 2rpx solid #E4CB9B;
				border-radius: 32rpx;
				display: flex;
				justify-content: center;
				align-items: center;
			}
		}
	}
	
	.nav {
		position: sticky;
		background-color: #fff;
		top: 0;
		z-index: 99;
		.active {
			color: #1F1F1F;
			font-weight: bold;
		}
	}
</style>
